#ifndef DEVICELINKER_H
#define DEVICELINKER_H

#include <vector>
#include <QDialog>
#include <QLabel>
#include <QTimer>
#include "MstStatistics.h"
#include "../common_typedef.h"

namespace Ui {
class DeviceLinker;
}

class DeviceLinker : public QDialog
{
    Q_OBJECT

public:
    explicit DeviceLinker(QWidget *parent = nullptr);
    void ConfigStaticHandler(MstStatisticsHandle stat) { m_stat = stat; }
    ~DeviceLinker();

signals:
    void SigLinkCmd(QString portName, LINK_CMD_TYPE linkType);

private slots:
    void InterfaceUpdate();
    void on_btFrame_accepted();
    void on_btDevLink_clicked();

private:
    Ui::DeviceLinker *ui;
    MstStatisticsHandle m_stat { nullptr };
    std::unique_ptr<QTimer> m_timr { nullptr };
    int m_comCountHis;
    std::string m_selectedOpt;
    QLabel* m_lastLabel { nullptr };

    void ClearComCollectionWidget();
    void SlotRefresh();
    void DevInfoRefresh();
    void CfgOptionStyle(QLabel* opt);
    QString GetOptionName() const;

protected:
    bool eventFilter(QObject *watched, QEvent *event);
};

#endif // DEVICELINKER_H
